<template>
  <div>
    <h2 class="public-title withdraw">提现
      <div class="progress-status">
        <ul class="progressbar" v-show="writeNub">
          <li class="success-last" style="width:135px">1.填写提现金额</li>
          <li :class="[flag>0?'success-last':'wait-first']" style="width:115px">2.等待审核</li>
          <li :class="[flag==2?'success-last':'wait']">3.交易完成</li>
        </ul>
      </div>
    </h2>
    <router-view v-on:statusFlag="statusFlag"></router-view>
  </div>
</template>
<script>
import bindCardComponent from "../../../components/personalCenter/bindCardComponent/bindCardComponent";
import setPayPsdComponent from "../../../components/personalCenter/setPayPsdComponent/setPayPsdComponent";
import { jsonToString } from "@/common/js/jsonToString";
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {
      cardmodalShow: false,
      setmodalShow: false,
      userAccountData: {},
      userBankedData: {},
      cardInfo: {},
      themoney: "",
      thepsd: "",
      waitDeal: false,
      writeNub: true,
      flag :false,
      myobj:{}
    };
  },
  computed: {
    ...mapGetters(["accountData"])
  },
  watch: {
    userAccountData() {
      this.SET_ACCOUNT_DATA({
        obj: this.accountData
      });
    }
  },
  created() {
    this.userAccountData = this.accountData;
    // JSON.parse(JSON.stringify());
    this.getCardbankInfo();
  },
  methods: {
    ...mapActions(["SET_ACCOUNT_DATA"]),
    statusFlag(val){
      this.flag =val;
    },
    bindCardNow: function() {
      this.cardmodalShow = true;
    },
    setpsdNow: function() {
      this.setmodalShow = true;
      
    },
    //获取提现银行卡信息
    getCardbankInfo: function() {
      if (this.userAccountData.is_banded_bank == "1") {
        this.$http
          .post(this.urlRequest + "?m=api&c=cash&a=getBankCard", {
            token: localStorage.getItem("token")
          })
          .then(res => {
            this.cardInfo = res.data;
          });
      }
    },
    //提现
    submit: function() {
      this.$router.push({
          path: '/topUpCenter/withdraw/present',
        })
      var params = {
        token: localStorage.getItem("token"),
        bank_id: this.cardInfo.bank_id,
        money: this.themoney,
        psd: this.thepsd
      };
      this.$http
        .post(this.urlRequest + "?m=api&c=cash&a=cash", params)
        .then(res => {
          this.myobj = res
          if (res.data.status == 0) {
            this.writeNub = false;
            this.waitDeal = true;
          }
        });
    }
  },
  watch:{
     '$route' (to, from) {
        if(to.path.indexOf("/topUpCenter/withdraw/present") != -1){
         this.flag = 1;
       }else{
         this.flag = 0;
       }
     }
  },
  components: {
    bindCardComponent,
    setPayPsdComponent,
  }
};
</script>
<style scoped>
.recharge .recharge-msg .cont .left {
  padding-left: 160px;
}
.recharge .recharge-msg .cont .left p {
  margin-bottom: 15px;
}
.recharge .recharge-msg .cont {
  border: 0;
  height: 250px;
  padding-bottom: 0;
  padding-left: 34px;
}
.pc-bottom .pc-left {
  min-height: 520px !important;
  background-color: red;
}
.pc-bottom .pc-right {
  border: 1px solid #eee;
  min-height: 575px !important;
}
.progressbar {
  margin-top: 13px;
}
.infostyle {
  position: relative;
}
.wjpsd {
  position: absolute;
  bottom: -20px;
  font-size: 12px;
  color: #9b9b9b;
  right: 0;
  cursor: pointer;
}
.recharge .recharge-msg .cont .left[data-v-5fa02685] {
  padding-bottom: 10px;
}
.moneystyle {
  position: relative;
}
.moneyIcon {
  position: absolute;
  width: 20px;
  height: 34px;
  text-align: center;
  line-height: 34px;
  left: 103px;
  color: #48484c;
}
.accountInfoStyle {
  display: inline-block;
  cursor: default;
}
.setpsd {
  color: #9b9b9b;
  font-size: 15px;
  font-family: PingFangSC-Medium;
}
</style>



// WEBPACK FOOTER //
// src/components/topUpCenter/withdraw/index.vue